improved the animations for text, refactored JS