Thanks, solved the problem!
Oh function names in Mathematica begin with capital letters. In fact, they are all written in what is called a CamelCase.
All of your if the statements should be If statements. Make that change and perhaps then your code will work as expected.