more refinements
http://jsfiddle.net/barakedry/xxg7fhj0/2/