Made changes to the code from comments and suggestions.