refact datamodel code with Q