fixed bug...

A Lesson in not coding late-night... now it is done and tested...