fix newlines and make a macro function safer with a do-while