Cleaned up code based on review suggestions