added some casting of values