Solved the error that occurs when fields are left empty