fixed the functionality