couple things to take note of...
be careful when naming variables & functions: don't use names like start, end, action, run etc - in case they turn out to be actual Lua functions/commands already - use abbreviated versions instead.
Also make sure you don't use same names for functions/variables multiple times - could create issues if you have more than one instance that isn't local to x script or function.
using "elseif" is better than "else if" as you only need to add one "end" instead of one for each "if" used.
final note: when using the short getObject method rather than full path method, you have to make sure you don't have multiple instances of whatever you are trying to retrieve.
-- cleaner method: we are directly linking to the object condition/value or whatever