full rewritten ngrest class