Refactoring: transfered database logic to separate class.