improved code and structuring