refactor dynamic variables functions