implementation of SELECT