updated functions styling and tidied