W4 when working in a different state

Hi, i am a NYS resident, but i work in NJ; how can i ensure i am getting taxed the appropriate amount? Last year i had to owe in state taxes, so i want to make sure i can correct that for this upcoming year tax filing. 

 

Thank you!