cleanup
added error check