refactored common.php