refactored UI, removed duplicate code