added comments and arranged according to dependency