Refactored some funky logic
Merge pull request #21 from erahm/authenticate

Refactored some funky logic