refactoring screen code