removed warnings and formatted the code