Fix to logging function