updated code for scaling  images