cleaned redundant code and added extra try/catch block