helper functions refactor