Refactored code for easier reusability in the rest of the set