Cleaned up and commented