check in the functional and query files I posted on apageofinsanity.wordpress.com