bug fix, refactor