small refactoring and a missing bracket
refactored with new methods