added error checking to compare