Added some error checking to keyword parsing