pure js PI stuff