code refining & cleanup