Added error handling to images