Restructured + Implemented Encoder