use long to prevent integer overflow