error handling added to deal with corrupted base64