added error checking for temp values