synchronizing query with table without changing ui - refactured