function now works in index.php on tests. Now to incorporate back into Txp