casting of int and error logging