Completelly refactored