added code to delete db instance and little bit of refactoring done