functioning put need to fix queries