Fix bugs in previous version