fixed once to work with multiple functions