fixed npe due to not having some null checks