Fixed pi indexing bug