naive hnf implementation