added authenticate function