changed double to int, potentially numerical overflow