bug fixing and function improvement