Added working code

Neater version of code used in SE101 SYSDEV assignment