Moved the x.lower() function call