added error checking on invalid operators