adding flexibility based on @chrisferagotti