moving totalImages from method parameter to be regular parameter