changed the API slightly due to various suggestions