bug fix, need rflactor