moved code where it should be