refactoring a few things