added if to check if category is not nil before adding it to a keyword

@nohahesham