anchor.diff:  process_post(ReqData, State) ->
       case api_help:is_search(ReqData) of
           false ->
  -            {UserJson,_,_} = api_help:json_handler(ReqData, State),
  -			case api_help:do_only_fields_exist(UserJson,?ACCEPTEDFIELDSUSERS) of
  -				false ->
  +			{UserJson,_,_} = api_help:json_handler(ReqData, State),
  +			UserName = lib_json:get_field(UserJson, "username"),
  +			Query = "{\"size\" :100,\"query\" : {\"term\" : {\"username\":\"" ++ lib_json:to_string(UserName) ++"\"}}}", 
  +			UserNameUnique = case erlastic_search:search_json(#erls_params{},?INDEX, "user", Query) of
  +								 {error, {Code, Body}} -> 
  +									 {Code,Body};
  +								 {ok, Json} ->
  +							   		lib_json:get_field(Json, "hits.total") == 0
  +							 end,
  +			case {api_help:do_only_fields_exist(UserJson,?ACCEPTEDFIELDSUSERS),UserNameUnique,UserName =/= undefined} of
  +		  		{_,_,false} ->
  +			  		{{halt,403}, wrq:set_resp_body("Username missing", ReqData), State};
  +				{false,_,_} ->
   					{{halt,403}, wrq:set_resp_body("Unsupported field(s)", ReqData), State};
  -				true ->
  +				{true,false,_} ->
  +					{{halt,409}, wrq:set_resp_body("Non unique username given", ReqData), State};
  +				{true,{Code1,Body1},_} ->
  +					ErrorString1 = api_help:generate_error(Body1, Code1),
  +		            {{halt, Code1}, wrq:set_resp_body(ErrorString1, ReqData), State};
  +				{true,true,_} ->
                       FieldsAdded = add_server_side_fields(UserJson),
   					case erlastic_search:index_doc(?INDEX, "user", FieldsAdded) of
  -						{error, {Code, Body}} -> 
  -							ErrorString = api_help:generate_error(Body, Code),
  -                    		{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  +						{error, {Code2, Body2}} -> 
  +							ErrorString2 = api_help:generate_error(Body2, Code2),
  +                    		{{halt, Code2}, wrq:set_resp_body(ErrorString2, ReqData), State};
                   		{ok,List} -> 
                       		{true, wrq:set_resp_body(lib_json:encode(List), ReqData), State}
   					end
  
positive.code:     Id = id_from_path(ReqData),
  	{UserJson,_,_} = api_help:json_handler(ReqData, State),
      %check if doc already exists
  	case api_help:do_only_fields_exist(UserJson,?ACCEPTEDFIELDSUSERS) of
  		false ->
  			{{halt,403}, wrq:set_resp_body("Unsupported field(s)", ReqData), State};
  		true ->
  			case erlastic_search:get_doc(?INDEX, "user", Id) of
  				{error, {Code, Body}} -> 
  					ErrorString = api_help:generate_error(Body, Code),
  					{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  				{ok, List} ->
              		case erlastic_search:index_doc_with_id(?INDEX, "user", Id, UserJson) of
                  		{error, {Code, Body}} -> 
                      		ErrorString = api_help:generate_error(Body, Code),
                      		{{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
                  		{ok, Json} ->
  		            		{true, wrq:set_resp_body(lib_json:encode(Json), ReqData), State}
              		end
      		end
  	end.
  
  
negative.code:                     end;
                  Id ->
  				    %% Get specific user
  					Query = "{\"size\" :100,\"query\" : {\"term\" : {\"username\":\"" ++ Id ++"\"}}}",
  					case erlastic_search:search_json(#erls_params{},?INDEX, "user", Query) of 
  						{error, {Code, Body}} -> 
  							ErrorString = api_help:generate_error(Body, Code),
                              {{halt, Code}, wrq:set_resp_body(ErrorString, ReqData), State};
  						{ok, Json} ->
  							ESId = lib_json:get_field(Json, "hits.hits[0]._id"),
  							case erlastic_search:get_doc(?INDEX, "user", ESId) of
  								{error, {Code1, Body1}} -> 
  									ErrorString1 = api_help:generate_error(Body1, Code1),
  									{{halt, Code1}, wrq:set_resp_body(ErrorString1, ReqData), State};
  								{ok,JsonStruct} ->
  									FinalJson = lib_json:get_and_add_id(JsonStruct),
  									{FinalJson, ReqData, State} 
  							end
  					end
              end;
          true ->                        
              process_search(ReqData,State, get)                        
  