Rebuilding check.php using Exceptions
Code optimisation