updated with styling and some optimisations