added functional programming implementation, argument parsing