Refactor ngrinder to be readable