fixing some stuff. may be unstable