updated logging function