stroke algorithm