fixed bug with async method calls, reformatted code