refactoring and cleaning up unecessary code