added error handling and keyword functionality