added checks on permutation string, made some functions global to
package