moved repeated lines to ctrl and used directives