Refactor user functions into separate script