refactor for multiple instances