Merged Ross' code