working version with no armadillo