fixed the duplicate function