Use indexOf remove redundant InArray function

By using indexOf you can remove the redundant InArray function