fix delete and handle error better