Moved implementation to a module

Script kept as an example of use