fixed improper sql queries, now app working