moved code to head