poll controller

moved some db queries to subs.