avoid using global varibles