move model code to proper class