Updated and Merged code