revert changes and fix errors plus aligning code

revert changes and fix errors plus aligning code