Corrected nesting of helper functions