Added checking for image type