Fix error causing a NullPointerException