Make sure to format your code pastes to they are easy to read on the forum; I suspect indentation will matter for your issue