Refactoring of helper functions