add check to avoid overflow