working uni-bi-tri-quad gram, cleaned up code:w