Changed API to be more flexible