add logging function