added back matlab code