Added basic support for view sql statements
Refactored