Teraain function improved.