Should complete or fix #77 at least its a start for this issue.

Ok this is a stab at #77 hopfully someone can have a look an possibly improve upon it.