Updated to use counter mode