Cleaned up php code