Updated UI behaviour, refactored code