server part + client part fixed some flaws