updated a lot, much more stable