Added a little bit of code refactoring