factored out some JS. Added loading input string from file