refactored all files to clean up code