refactor code and file structure