trying to minimise and understand code
updated all code and minimised size