added missing includes and replaced if_else with seldec