added new functions + small refactoring