updated the n and alpha functions with closed-form expressions, cleaned up some code