Code refactorization + added new functionalities