new code and small fix