Modified the logic in the init method (former initialize method)