rewriting xEssentials for better performance