adapted to kometphp