Added some logic functions