some code about algorithm