add purity to function