refactor by removing parameter and including in Array class