refactor to prevent shiting in window