change function decorator to work correctly