code to generate array loading
refactor methods