add data type check to avoid false exceptions