some bug fixing and update old functions