smart argument parsing (oh the shitty code)