Prevent NullPointerException on corner cases