Add logic to functions