working version of cramer