added -h flag
refactored some stuff