Fixing and adding try and catch