select date not working, reorder functions.