function now accepts objects