viewsand sql queries refactored
queries refactoring