Test OK. Now I need to make things neater...
Deleted some debugging printing