Refactoring move window script