fix second to last function