[@Stern Algorithm] This kind of thing would fit you well.