Improve naming and indentation. Add comments