Almost final wersion - refactoring is needed