Made changes following @timgraham suggestions.