Final code, integrated, fixed bug when image did not return it self