some functions from selection moved to functions