further refactoring
finished refactoring, working bad as before