Heavy optimization on algorithm