Refactor

Also adding comments