Refactoring to make it handle arbitary languages