Fast implementation. Need refactoring