fix bad image check and improve it too