Refactoring. Added api