fix bug for undersized images