fix bug in insertion of guards to prevent use before definition