Slight refactor, added authentication.