added a check for empty fields