Fixed error in helper function