move requestanimframe to top of function in case it falls back to set timeout