Removing duplicate logic