Made changes following @timgraham suggestions. Take 2