code now passed jshint with one error (about the legit fallthrough)