Modified as per @tomspillman request