Finalized code for processing join results read from JOIN table