"global name reverse not defined" fixed