fixed #8, checking fields before using them