edited markup, element collection moved from global scope, if replaced with switch, refactor code in accordance with standarts