add nickName unique validation and refactor code.