Updated code.Fixed bugs.