added Josefs refactoring