refactoring, added logic, updated UI