fixed formatting
fixed a bug and tidied formatting