refactor position parsing