Use partition instead of map