more flexible version