replace printf with logger
check the memory
minor refactor
minor refactor code
minor change