Refactor machine index method to improve data retrieval and sorting
