better function automatic method

function automatic method