refactoring and stuff