clear error message if it is successful
wrapped clearing of error in if block