some refactoring, code is even prettier now