code for multiple passes