use xoppa's idea as per PR discussion