Added error handling, in case the image was unable to be loaded.