Variables not assigned properly