fix multiple bugs