checks for errors too