Added new functions and increased code reusability