Added a check in hit_pipe function