Added  exception handling