fixed typos / added error handling