Fixed duplicated code