edited logic, removed loophole, added chips count