minor bug fix, minor refactor.