refactoring and cleaning up a little