added error handling and grapph colours