Changed implementation to use extension methods