added summary, refactored the header, fixed bugs