Tidying up the settimeout logic
Adding logging