Its a surprisingly long function. Consider (eventually) refactoring to move to your thumbnail list class maybe?