Refactoring and added PathArray class