Merging Whit's code