Code now works with old and new trial numbering systems