changed from using 16-bit to 32-bit arithmetic for pos_funct