add new Q4 function to avoid seg faults