need to move else on the same line as this bracket as shown in Moodle coding style guidelines