trying to make KX logic slightly more readable