It was a bad idea to define a function inside another function. Please move it out of the step definition.