refactor code into separate files