Added an array and some refactoring