Updated encode and added decode LSB