fix #376 for real and more cleanly