Added an error check