ik: Extract update function and add direction toggling.