added helper functions to prevent animation glitches