Moved calc_jphi back into else statement