Merged code- Need to test it