modularized functions and added animations