Split into functions, put into module
Adds minified version