some fixing, still not working quite well