added polyfill and fixed animation bug