some refactorings in preparation for join and avoiding errors