Added some error checking to pal.php