Update 2 with speed optimization