Added more sensible boundaries code