refactoring and moving some stuff