If memory is an issue then you need to re-hash the index into proper index ravenous Posting Pro in Training 696 posts since Jul 2005 Reputation Points: 264 [?] Q&As Helped to Solve: 115 [?] Skill Endorsements: 13 [?] 0 3 Years Ago You can save some space by just losing all the temporary variables, but your basic algorithm is pretty much the fastest you can do in general.