using solve instead of ginv function