Changed getFirst to peekFirst to avoid exception