Common function for getting username