moved the join operations out of the block - they can be performed by join