Fixed javascript order to fix button bindings