solved length and last function