Moved common code to new snippet