Changed method for finding functions [WIP]

The earlier method of finding func was incomplete. This new method is more robust and less likely to fail. This method is still in progress.
make sure to put spaces around the relational operators like `!=` -- a quick find and replace should fix this.