Bugfix for Firefox

Define functions before they are called