merge code
add check user login and registion, there are some exception