added array key lookup to lib.php