Moved functions out from basic.php