Added missing exception handling logic