adding small error checking