refactor win, draw and lose checks into functions