refactor code to new file