Code refactor with updates