Fixed overflow error check