Add zero padding method
Add null check
Change ternary operator to if else