problems with the sql
deleted unused junk;more conventional naming