refactor brakeman

I refactor some methods for the Brakeman class

maybe it can enhance the quality of the code in some ways.

If you feel OK, consider to merge it