code rebuild and add log function