Added some error checking

Checks for mandatory fields