Fixed control association and renamed some temp variables to be more clear