bug fix in lib.php