more progress
function rewrite