animate function improved