Added authenticateUser function