Used Andre's version of data encoding