Code adjustment

Code is almost ready for debugging