some improvment and bug fixing