missing "end"

Error message: 'end' expected (to close 'function' at line 885) near '<eof>'