Cleaned up and improved