exception handling and extracting some methods