Fixes #764
solution cooked up by DarkSir23 small modifications by me.