fix bugs in previous commit