implement the logic layer