revamp with complete log function