minor refactor & support for IOS4.3.
quick refactor
removed duplicated code logic
formatting