refactoring: moved some stuff around