fixed up view and queries