combine active record & linq style, refactor  & simplify basic functions