made linear_encode

very similar to shift encode