code refractoring to support xcode