Cleaned up and tested