split up big function
get type right
split up big function
remove redundant var
add some whitespace
factor out form lookup
split up big function
remove redundant parens