add algorithm code