adding factorize function