utility functions refactored to separate JS file