fix previous commit that does not work (remove requirement tr)
reorganize and cleanup