rejig code to handle auth credentials; should now handle all cases apporopriately