fixed bug assigning gender, refactoring of the back end