had to change some of the sql commands around