fix potential NullPointerException

also remove one unused import