changed added temp prefix to all local variables to remove scope errors