refactored with methods + new window log
which function fix