add comments and remove magic constant numbers