Corrected definition of helper functions