trim out logic