reduce log for savedb
add error logging and refactor codes