Moved methods for generating pi function to a separate class