bug fix lib.php