Fix origin check code