last function fixed