Replace Promise with standard callback implementation.
Use === instead of == for comparision.
Reformat code for consistency.