use lookuptable instead of calculating the offset every loop