refactoring in gui & database