fix the re-entering bug