check the validity of locations before rewriting

make sure LAngleLoc and RAngleLoc are valid