added algorthim comments