Formatted code and added docblocks