Fix #12 with thanks to Scott Walker