aaron. added loggin funtion. Nearly works 100% need to sort controller out.