added parsing for options from the command line
split up tasks into functions for better readability