Revert "Optimise the code."

This reverts commit f443c5ed1f902fbd6cd0a9a27ad5e8408a023553.
revert small changes and formatting.

.