modified lib.php to add storeid funtion