Factorize function seems to work