fixed reassign issue and formatted new code