adjusted authentication function