fromString and toString methods