Changed from check_output to manual method