added try-catch block for invalid id deletion