tidied up logging codes