debug and restructurig