rewrote animation logic