writing out logic