changed query in stage 6 to not create an array first