Fixed image resizing and stop logic