minor optimization related to / % and lookup table