Made changes to reflect updated matlab code