cleaned up php code