Right before switch to ray