Why doesn't the 'else' condition work?