Refactor function location