Adding in errorhandler and notfoundhandler
Moving block query into a sql file and typecasted