bugs fixed but still refactoring