use print instead of puts to avoid thread problem