tbh, it's a copy paste from Joomla module... since it was working, I just copied the code
where do you see the mistake exactly?