Updated the code structure removing some initial redundancies and
optimizing