Extract common functionality