Yikes! this function makes my head hurt!