using array.shift() for added elegance