completed initWindow func