(xSaI) Refactor some code