tweaked scala impl for mixed case