works with 32 bit optimization, poor style
working 32 bit optimization, need to change everything to unsigned