rewritten to use aTRAM's functions instead.