Updated lines 138-141 and 249 until end