fixed overflow thing by casting to long instead of int