fixing another previousState null error