My algorithm code