fixing undefined bugs#1