small changes to avoid a NullPointerException