refactor: rewriting functionalities and added additional helper functions