redesigned parse_commands method