Updated window procedure