I can have a look but there's a lot of if statements in that code!