added optional window mode