Added double overflow prevention