added logging function