Removed duplicated code

Just for the recort. https://tracker.moodle.org/browse/MDL-48640