changed query if type is user or not