Added more logic to create a dicctionary