finished with refactoring. one bug left
final version of the day - not yet working