Moved handler registration earlier