Remove the last undefined values