adjusted javascript to be css animation-frendly