Added helper functions in comments