Made this a library

Will add an example etc to show how to use.