Some problem: global vars nills somwhere