refactorin Array.remove method