organising and reworking some of the code