code cleared and fixed for animate timing