updated checking code