first matlib implementation working