fixing enconder functions