Fixed log function