stable version(need refactoring, because look like a shit)