modularize code and move license to its own file