eddited select() function