fixed bug for fixed windows and cleaned code