added empty array check for addFirst() method