handling first and last