updated output format
new randomize function
refactored