refactored code for use with filestore.php linked class file