incorporated suggestions from @certik and @dagss