Fixed functions and separated to sync and async