Fixed missing perror and changed structure of prompt function