answering Bryan's critiques, removed commented code, made params[2] easier to understand