Added a lot of improvemets and buggy code