cleanup ajax code