minor fix - proper error checking