fix delete data query;
clean up code