refactored check for winning lines