added more to matlab implementation