added catching of typeerror