updated some code 2014-11-6 By MACZ