added code to auto-update based on Utkarsh's suggestions