Extract return param processing and make it more flexible