$temp is a poor variable name! but it isn't your fault I guess