converted animLoop to a switch case