fixed timing issue in map js