Functions are made private and minor improvement