Logic added

All db queries from UI are done through Logic class.