Removing wrong duplicated code