Fixed bug in MAD