changed select function as prof said