refacted but not fix bug