Attempt to solve issue #11

This is my attempt to solve issue #11 - needs testing, there is an issue when I try to compile on line 114 however..