split out functionality