It would be helpful if you could describe the code (ie pseudocode).