Moved code into action to be as late as possible