eliminate repeated select and code cleanup