Clean up error message output and if statements