This code is badly indented. Maybe you accidentally used tabs here?