Changed Logic from code Review feedback