added proper authentication handling