Modified not to use try catch, but if.