implemented rudimentary error handling