Fixing a bug for array method