Merge "Refactor: Improve null safety and simplify branch conditioin"