refactored code; upgraded ui slightly