refactoring

cleaning up code to be less complex.