Formatted and edited some logic error