rework login detection to be cleaner