fix bugs due to wrong operation