refactored to use function argument to update scope

Using function arguments to populate profiles list.