move out sql queries from views
do not change cursor above moveless headers