cleaning up the duplicated codes