fix bug with overflow