Changed code. Added the "else" part of the code.