avoid reading .jpg file & cleanup code