Code refine. Removed some unnecessary logic