reorganized animation code to use blocks