Added some control logic