write tmp calculate function framework