added code for fourth version