optimized ulam a little