rewrite to support "user"
add lock and fix some even bug