modify array name and add error handling