changed db quering from main view