fix logging function