changed the order of prefilling and loggin in