Code for first version