make functions synchronous to maintain chronological order