refactored screen handling