handle null instead of using NullPointerException.