refactor authentication if/else statements