Cleaned up and simplified