First wersion, need refactoring