Code refactor with formatting.