finished mrd and added plotting functions