fleshed out the prolog querying, the whole thing works!
added some documentation and cut out some commented code