Refactor position controller