First attempt at encoding