Illegal OPTION DECLARE after implicit declaration

You used an implicit declaration before the Option Declare statement.

Move the Option Declare statement so that it appears before all variable declarations.