move functions out of the main sprite function
inline return statement in normalizeRest function