Code refactor for easier reading