solution was refactored, several tests was added