Added an error check.