this gem seems to work quite nicely!