As a safety pilot you are a required crew member and allowed to log PIC per the regs...but only while the other guy is under the hood. When he is visual, you are not a required crew member and cannot log PIC or total time. Sounds like you're doing it right.