tidying up cipher and added matrix multiplier