refactored and added methods to array class