First attempt at the code