second version of code