Merged two versions of code