reformatted code in intellij, fixed errors