Added checks and XML functions