updated to be suitable on 32bit platform