bug fixing and improvment