Added error checks for empty fields