WORKING ENCODER (Final Update no.3)