used back() instead of index