fixing object for json and db and conditioning some selects