updated code / formatted