fixed generation of join