Checking value size and type to avoid a random crash