Corrected function call so it waits for then