result was not declared outside try