minor tweaks to animation algorithm