Refactor for more performance and readibility.