fixed error in last function