Added basic encoding. DOES NOT WORK PROPERLY.