implemented focusing first or last element