Updated Accel Function so that is doesn't live in the main loop