firefox addon code refactored