add intermediate tables
backup
refactored