refactor to use arrays