just for algorithm exerise