Add error handling when dealing with invalid id