moved code into separate scope