refactor authentication service for better code, and fix #33