refactored DB code and added more UI reporting