refactor code to remove value provider