refactored for tas, added some docs