solved the ALG exercise