try checking out the array methods (the back of the pickaxe book has a list) and I think you will find one that does what you want - you are on the right track.