updated some code By MACZ