New functions plus tests