some refactoring
made a mess