I'm concerned about the indenting here. It looks to me like this wouldn't run.
Are you using tabs _and_ spaces?