refactored and fixed bug w animation