Add comments and restruc code