Refacoring!!!!
test encode