working version after revise