[encription] finished implementing the function, still fixing some bugs.