firts workable prototype after refactoring