Formatted code and added documentation