Updated :: Changed logic to be more readable