There is an error here. There are 2 'end' closing the if-else clause. This 'end' and the one in the previous line. Also, please fix the indentation for 'else' and subsequent block.