Added Variable capture logic