Refactor stroke setting into a separate method