fixes #1 . using shift instead of pop, to account for sorting used