move finding of main image to controller