added kmd function