reorganized loginUI code